package org.xm.sk.vo.tb;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.xm.sk.vo.Base;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_brand")
@ApiModel(value = "Brand", parent = Base.class, description = "品牌")
public class Brand extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = 3336807176921153385L;

    @ApiModelProperty(value = "品牌名称")
    @Column(length = 255)
    private String name;

    @ApiModelProperty(value = "品牌下门店")
    @JsonIgnore
    @OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "brand")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Shop> shops = new HashSet<Shop>(0);
    
    @ApiModelProperty(value = "品牌下门店ID集")
    @Transient
    private Set<Integer> shopIds = new HashSet<Integer>(0);
    
    @ApiModelProperty(value = "品牌下门店名称集")
    @Transient
    private Set<String> shopNames = new HashSet<String>(0);
    
    @ApiModelProperty(value = "门店适用的优惠活动")
    @JsonIgnore
    @ManyToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "brands")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Activity> activitys = new HashSet<Activity>(0);

}
